#include<bits/stdc++.h>
using namespace std;

int a[4], b[4];

signed main() {
	int n;
	cin >> n;

	int ans = 0x3f3f3f3f;
	for (int i = 1; i <= 3; i++) {
		cin >> a[i] >> b[i];
		int t = ceil( 1.0 * n / a[i]) * b[i];
		ans = min(t, ans);
	}
	cout << ans;
	return 0;
}
